Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit ef9244f79fa35ec0b25d500080fe3583c6000d8b


Parents : 2d811dc
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-07-20T11:49:09+02:00

Store interface hashes instead of recomputing every time

Changes

1 files changed, 5 insertions(+), 5 deletions(-)


Diff

diff --git a/RNS/Interfaces/Interface.py b/RNS/Interfaces/Interface.py
index 6759ea3f4..4553fba16 100755
--- a/RNS/Interfaces/Interface.py
+++ b/RNS/Interfaces/Interface.py
@@ -102,6 +102,7 @@ class Interface:
self.online = False
self.bitrate = 62500
self.HW_MTU = None
+ self.__hash = None
self.supports_discovery = False
self.discoverable = False
@@ -139,7 +140,8 @@ class Interface:
self.op_freq_deque = deque(maxlen=Interface.OA_FREQ_SAMPLES)
def get_hash(self):
- return RNS.Identity.full_hash(str(self).encode("utf-8"))
+ if not self.__hash: self.__hash = RNS.Identity.full_hash(str(self).encode("utf-8"))
+ return self.__hash
# This is a generic function for determining when an interface
# should activate ingress limiting. Since this can vary for
@@ -364,11 +366,9 @@ class Interface:
@staticmethod
def get_config_obj(config_in):
- if type(config_in) == ConfigObj:
- return config_in
+ if type(config_in) == ConfigObj: return config_in
else:
- try:
- return ConfigObj(config_in)
+ try: return ConfigObj(config_in)
except Exception as e:
RNS.log(f"Could not parse supplied configuration data. The contained exception was: {e}", RNS.LOG_ERROR)
raise SystemError("Invalid configuration data supplied")
\ No newline at end of file


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────